A typical code smell known as unused function parameters refers to parameters declared in a function but not used anywhere within the function’s
body. While this might seem harmless at first glance, it can lead to confusion and potential errors in your code. Disregarding the values passed to
such parameters, the function’s behavior will be the same, but the programmer’s intention won’t be clearly expressed anymore. Therefore, removing
function parameters that are not being utilized is considered best practice.
This rule raises an issue when a private
procedure of a Class
, Module
or Structure
takes a
parameter without using it.
Exceptions
This rule doesn’t raise any issue in the following contexts:
- Procedures decorated with attributes.
- Empty procedures.
- Procedures which only throw
NotImplementedException
.
- Main methods.
-
virtual
, override
procedures.
- Interface implementations.
- Event handlers.